library(tidyverse)
library(readxl)
path = "Excel/648 Both Perfect Square and Perfect Cube.xlsx"
test = read_excel(path, range = "A1:A21")
result = data.frame(`Answer Expected` = 1:20) %>% map_dfr(., ~.x ^ (2 * 3))
all.equal(result$Answer.Expected, test$`Answer Expected`)
#> [1] TRUEExcel BI - Excel Challenge 648
excel-challenges
excel-formulas
🔰 List the first 20 numbers which are both perfect square and perfect cube.

Challenge Description
🔰 List the first 20 numbers which are both perfect square and perfect cube.
Solutions
- Logic: Read the workbook ranges needed for the challenge.
- Strengths: The code maps the workbook rule into a compact, reproducible pipeline.
- Areas for Improvement: The solution assumes the workbook layout and selected ranges remain stable, so any structural change in the sheet would require small adjustments.
- Gem: The elegant part is how little code is needed once the correct intermediate representation is chosen.
import pandas as pd
path = "648 Both Perfect Square and Perfect Cube.xlsx"
test = pd.read_excel(path, usecols="A", nrows=21).squeeze().tolist()
result = [x**(2*3) for x in range(1, 21)]
print(result==test) # TrueThe Python version keeps the algorithm explicit, which helps when the challenge depends on a greedy or iterative rule.
Difficulty Level
Easy / Medium
The business rule is clear, though the workbook still needs a few transformation steps to reach the expected output.